<!--suppress ALL -->
<template>
    <div class="page historyPoliceApply-page" data-page="historyPoliceApply" style="z-index: 2;">
        <div class="link-page-nav">
            <a href="#" class="link" @click=$root.backToTab()>
                <i class="iconfont icon-zuo"></i>
            </a>
        </div>
        <div class="link-page-search">
            <div class="historyPoliceApply_title" style="float: left">接处警</div>
            <div class="link-page-search-input" style="width: 58%">
                <i class="iconfont icon-APPicon_sousuo1"></i>
                <input type="text" placeholder="搜一搜" id="historysearch-contant">
            </div>
            <a class="link popover-open" data-popover="#dector_menu">
                <i class="iconfont icon-APPicon_shaixuan1" id="active" style="font-size:24px"></i>
            </a>
        </div>
        <div class="select-option-fixed">
            <div class="history-type-select">
                <div class="history-col history-type-select-select" @click="selectCurrentType(0,0)">未复位</div>
                <div class="history-col" @click="selectCurrentType(1,1)">已复位</div>
                <div class="history-col" @click="selectCurrentType(2,-1)">全部</div>
            </div>
        </div>
        <div data-infinite-distance="50" class="page-content infinite-scroll-content ptr-content pdbottom120"
            @infinite="loadMoreHistoryList" @ptr:refresh="refreshHistoryPolice">
            <div class="ptr-preloader" style="top: 20px;">
                <div class="preloader color-multi"></div>
                <div class="ptr-arrow"></div>
            </div>
            <div class="list media-list no-hairline-bottom  search-list searchbar-found"
                style="padding-top:60px;margin: 10px 20px;" id="historyPolice_list">
                <ul></ul>
            </div>
            <div id="history_preloader" class="preloader infinite-scroll-preloader"></div>
        </div>
        <div class="popover select-option-con" id="dector_menu">
            <div class="popover-angle"></div>
            <div class="popover-inner">
                <div class="list">
                    <ul>
                        <li><a href="" class="list-button item-link popover-close" id="history_org">选择单位</a></li>
                        <li><a href="" class="list-button item-link hide" id="history_fbs">选择建筑物</a></li>
                        <li><a href="" class="list-button item-link popover-close" id="history_type">设备类别</a></li>
                        <li><a href="" class="list-button item-link popover-close" @click="getTbTime"
                                id="history_date">选择日期</a></li>
                        <li><a href="" class="list-button item-link popover-close" id="history_policeType">警情类型</a></li>
                        <li><a href="" class="list-button item-link popover-close" id="history_isDeal">是否处理</a></li>
                        <li><a href="" class="list-button item-link popover-close removeScreen select-active"
                                @click="removeScreen">清&nbsp&nbsp&nbsp&nbsp&nbsp空</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</template>
<style scoped>
    .historyPoliceApply_title {
        padding-right: 20px;
        font-size: 24px;
        font-weight: bold;
        color: #000;
        background-color: #fff;
    }

    .select-option {
        padding: 10px 5px;
        background-color: #ffffff;
        font-size: 12px;
        width: 100%;
    }

    .history-type-select {
        width: 100%;
        height: 40px;
        line-height: 40px;
        background-color: white;
    }

    .history-type-select div {
        text-align: center;
        font-size: 14px;
    }

    .imgicon {
        width: 39px;
        height: 39px;
        border-radius: 5px;
        background: #eaeaea;
    }

    #historyPolice_list .decter-no-border,
    #historyPolice_list .decter-yes-border {
        display: inline-block;
        height: 20px;
        line-height: 20px;
        padding: 0 5px;
    }

    .item-title span {
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
    }

    .click-contaier {
        z-index: 6;
        position: absolute;
        right: 16px;
        top: 18px;
    }

    .maintitle {
        width: 95%;
        padding-left: 5px;
        font-size: 14px;
    }

    .img_bqq {
        /*width: 45px;*/
        padding-top: 1.5px;
        height: 17px;
    }

    .linenumber {
        color: #333333;
        /*padding-top: 5px;*/
        font-size: 15px;
        padding-left: 0px;
        -webkit-line-clamp: 1;
        display: -webkit-box;
        /*-webkit-box-orient: vertical;*/
        overflow: hidden;
        white-space: nowrap;
        width: 100%;
    }

    .icon-size {
        font-size: 22px !important;
    }
</style>
<script>
    return {
        mounted() {
            var self = this;
            var app = self.$app;
            //页面传参
            self.fireTTypes = this.$route.params.fireTType;
            self.historyOrgId = this.$route.params.orgid;
            self.handlerStatus = this.$route.params.handlerStatus;
        },
        data: function () {
            return {
                historyOrgId: 0,
                historyList: [],
                allowInfinite: true,
                fireSystemId: -1, //获取全部填-1
                fireBuildingId: '', //消防建筑物id（包含子集） 获取全部填0
                fcfCategoryId: -1, //设备类别-1;
                fireTTypes: -1, //-1全部 0:正常 10:火警, 20:故障,30:屏蔽
                pageIndex: 0,
                pageSize: 25,
                startTime: '',
                endTime: '',
                selectContent: '',
                selectOptionOrg: "",
                selectOptionDec: "",
                isRest: 0,
                isDeal: "",
            }
        },
        methods: {
            onChooseFbs(relateBuildIds,texts) {
                this.relateBuildIds = relateBuildIds
                if (relateBuildIds) {
                    jQuery('#history_fbs').addClass('select-active')
                    jQuery('#history_fbs').html(texts)
                } else {
                    jQuery('#history_fbs').removeClass('select-active')
                    jQuery('#history_fbs').html('选择建筑物')
                }
                this.fbsPopup.close()
                this.reInit();
                this.clearContent();
                this.getHistoryPoliceList();
            },
            getUserBuildByAccount() {
                Dao.getUserBuildByAccount({
                    account: userInfor.accountName,
                },  (res)=> {
                    if (res&&res.relateBuildIds) {
                        this.originalBuildIds=res.relateBuildIds
                        this.relateBuildIds=''
                        jQuery('#history_org').addClass('hide')
                        jQuery('#history_fbs').removeClass('hide')
                    }
                    this.getHistoryPoliceList()
                })
            },
            backToRefresh: function () {
                var self = this;
                self.ischangeAlarming()
            },
            ischangeAlarming: function () {
                let getAlarming = JSON.parse(localStorage.getItem("ilink-alarming-push"))
                let getAlarmingIds = getAlarming.id
                let getAlarmingId = []
                if (getAlarmingIds.toString().indexOf(",") == -1) {
                    getAlarmingId = [getAlarming.id]
                } else {
                    getAlarmingId = getAlarming.id.split(",")
                }
                let $ul = $("#historyPolice_list ul").children()
                for (let i = 0; i < $ul.length; i++) {
                    for (let j = 0; j < getAlarmingId.length; j++) {
                        if (getAlarmingId[j] == $ul.eq(i).find(".alarming-kepp-now span").attr("data-id")) {
                            if (getAlarming.handlerStatus == 1 && $ul.eq(i).find(".alarming-being-processed").attr(
                                    "data-isReset") == 0 && getAlarming.resetMode == 1) {
                                $ul.eq(i).empty()
                            } else if (getAlarming.handlerStatus == -1 && $ul.eq(i).find(
                                    ".alarming-being-processed").attr("data-isReset") == 0) {
                                $ul.eq(i).find(".alarming-kepp-now span").html("立即处理")
                                $ul.eq(i).find(".alarming-kepp-now span").attr("data-handlerstatus", -1)
                                $ul.eq(i).find(".alarming-being-processed").html("&nbsp;&nbsp;未复位&nbsp;未处理")
                            } else if (getAlarming.handlerStatus == 2 && $ul.eq(i).find(".alarming-being-processed")
                                .attr("data-isReset") == 0) {
                                $ul.eq(i).find(".alarming-kepp-now span").html("继续处理")
                                $ul.eq(i).find(".alarming-kepp-now span").attr("data-handlerstatus", 2)
                                $ul.eq(i).find(".alarming-being-processed").html("&nbsp;&nbsp;未复位&nbsp;处理中")
                            } else if (getAlarming.handlerStatus == 1 && $ul.eq(i).find(".alarming-being-processed")
                                .attr("data-isReset") == 0) {
                                $ul.eq(i).find(".alarming-kepp-now").empty()
                                $ul.eq(i).find(".alarming-kepp-now span").attr("data-handlerstatus", 1)
                                $ul.eq(i).find(".alarming-being-processed").html("&nbsp;&nbsp;未复位&nbsp;已处理")
                            } else if (getAlarming.handlerStatus == -1 && $ul.eq(i).find(
                                    ".alarming-being-processed").attr("data-isReset") == 1) {
                                $ul.eq(i).find(".alarming-kepp-now span").html("立即处理")
                                $ul.eq(i).find(".alarming-kepp-now span").attr("data-handlerstatus", -1)
                                $ul.eq(i).find(".alarming-being-processed").html("&nbsp;&nbsp;已复位&nbsp;未处理")
                            } else if (getAlarming.handlerStatus == 2 && $ul.eq(i).find(".alarming-being-processed")
                                .attr("data-isReset") == 1) {
                                $ul.eq(i).find(".alarming-kepp-now span").html("继续处理")
                                $ul.eq(i).find(".alarming-kepp-now span").attr("data-handlerstatus", 2)
                                $ul.eq(i).find(".alarming-being-processed").html("&nbsp;&nbsp;已复位&nbsp;处理中")
                            } else if (getAlarming.handlerStatus == 1 && $ul.eq(i).find(".alarming-being-processed")
                                .attr("data-isReset") == 1) {
                                $ul.eq(i).find(".alarming-kepp-now").empty()
                                $ul.eq(i).find(".alarming-kepp-now span").attr("data-handlerstatus", 1)
                                $ul.eq(i).find(".alarming-being-processed").html("&nbsp;&nbsp;已复位&nbsp;已处理")
                            }
                        }
                    }

                }
            },
            removeScreen: function () {
                var self = this;
                if (userInfor.isMuilUnitUser == 1) { //多
                    self.selectOptionOrg = "";
                    self.historyOrgId = userInfor.organizationIds;
                    self.orgIds = userInfor.organizationIds;
                    jQuery("#history_org").html("选择单位");
                    jQuery("#history_org").removeClass('select-active');
                }
                self.selectOptionDec = "";
                self.fireSystemId = -1;
                self.fcfCategoryId = -1;
                jQuery("#history_type").html("设备类别");
                jQuery("#history_type").removeClass('select-active');

                self.selectOptionIndex = "";
                self.startTime = '';
                self.endTime = '';
                jQuery("#history_date").html("选择日期");
                jQuery("#history_date").removeClass('select-active');

                $("#history_policeType").removeClass("select-active");
                jQuery("#history_policeType").html("警情类型");
                self.fireTTypes = -1;
                selectOptionIndex2 = "";

                $("#history_isDeal").removeClass("select-active");
                jQuery("#history_isDeal").html("是否处理");
                self.isDeal = "";
                selectOptionIndex1 = "";

                this.relateBuildIds=''
                jQuery('#history_fbs').removeClass('select-active')
                jQuery('#history_fbs').html('选择建筑物')

                self.reInit();
                self.clearContent();
                self.getHistoryPoliceList();
            },

            refreshHistoryPolice: function (e, done) {
                if (done && e) {
                    var self = this;
                    var $ = self.$$;
                    setTimeout(function () {
                        self.reInit();
                        $('#history_preloader').hide();
                        self.getHistoryPoliceList();
                        done();
                    }, 1000);
                }
            },
            selectCurrentType: function (num, type) { //0 -1
                indexHistoryPoliceApply = num;
                if (getClickEnabel()) {
                    var self = this;
                    var $ = self.$$;
                    $(".history-type-select div").removeClass('history-type-select-select').eq(num).addClass(
                        'history-type-select-select');
                    self.isRest = type
                    self.reInit();
                    self.getHistoryPoliceList();
                }
            },
            //时间筛选
            getTbTime: function () {
                var self = this;
                let date = common.getTimeArray(1);
                selectOptionFn(date, function (data) {
                    jQuery("#history_date").empty();
                    if (self.selectOptionIndex != data.index) {
                        var timeArr = data.name;
                        jQuery("#history_date").html(timeArr);
                        jQuery("#history_date").addClass('select-active');
                        self.selectOptionIndex = data.index;
                        self.startTime = timeArr.replace("年", "-").replace("月", "-") + "01" + " 00:00:00";
                        let endDay = mGetDate(self.startTime.split("-")[0], self.startTime.split("-")[1]);
                        self.endTime = timeArr.replace("年", "-").replace("月", "-") + endDay + " 23:59:59";
                    } else {
                        self.selectOptionIndex = "0";
                        self.startTime = "";
                        self.endTime = "";
                        jQuery("#history_date").html("选择日期");
                        jQuery("#history_date").removeClass('select-active');
                    }
                    self.reInit();
                    self.clearContent();
                    self.getHistoryPoliceList();
                }, self.selectOptionIndex);
            },
            getHistoryPoliceList: function () {
                var self = this;
                var $ = self.$$;
                //筛选按钮有值变色
                if (jQuery("#history_type")[0].innerText != "设备类别" || jQuery("#history_org")[0].innerText !=
                    "选择单位" || jQuery("#history_date")[0].innerText != "选择日期" || jQuery("#history_policeType")[0]
                    .innerText != "警情类型" || jQuery("#history_isDeal")[0].innerText != "是否处理"||jQuery("#history_fbs")[0].innerText != "选择建筑物") {
                    jQuery("#active").addClass("select-active");
                } else {
                    jQuery("#active").removeClass("select-active");
                }
                /*           self.startTime=this.$route.params.startTime;
                          if (self.startTime==0){self.startTime=undefined}
                          self.endTime=this.$route.params.endTime;
                            if (self.endTime==0){self.endTime=undefined} */
                //警情设备列表
                let params = {
                    orgIds: self.historyOrgId,
                    fireSystemId: self.fireSystemId == -1 ? "" : self.fireSystemId,
                    categoryId: self.fcfCategoryId == -1 ? "" : self.fcfCategoryId,
                    fireBuildingId: self.fireBuildingId == -1 ? "" : self.fireBuildingId,
                    fireTType: self.fireTTypes == -1 ? "" : self.fireTTypes, // 报警分类
                    pageIndex: self.pageIndex,
                    pageSize: self.pageSize,
                    startTime: self.startTime,
                    endTime: self.endTime,
                    queryContent: self.selectContent, // 消防设施名称、位置
                    handlerStatus: self.isDeal == "" ? "" : self.isDeal, // 处理状态
                    dataType: self.isRest == -1 ? "" : self.isRest, // 是否复位、 0实时/1历史
                    continueTimeUnit: 3,
                    relateBuildIds:this.relateBuildIds||this.originalBuildIds
                }
                for (var k in params) {
                    if (params[k] === '') {
                        delete params[k]
                    }
                }
                Dao.getFcfHistroyDataList(params, function (_data, total) {
                    let data = _data ? _data.listData : []
                    if (self.pageIndex == 0) {
                        $("#historyPolice_list ul").empty();
                    }
                    if (data && data.length > 0) {
                        if (self.pageSize * self.pageIndex + data.length < total) { //没分页
                            $("#history_preloader").show();
                            self.allowInfinite = true;
                        } else { //有分页
                            $("#history_preloader").hide();
                            self.allowInfinite = false;
                        }
                        for (var i = 0; i < data.length; i++) {
                            //  10 火警 20 故障 30 屏蔽 40联动
                            var dealResultHtml = "";
                            if (data[i].isReset == 0) {
                                dealResultHtml += `&nbsp;&nbsp;未复位`;
                            } else {
                                dealResultHtml += `&nbsp;&nbsp;已复位`;
                            }
                            if (data[i].handlerStatus == -1) {
                                dealResultHtml += `&nbsp;&nbsp;未处理`;
                            } else if (data[i].handlerStatus == 2) {
                                dealResultHtml += `&nbsp;&nbsp;处理中`;
                            } else {
                                dealResultHtml += `&nbsp;&nbsp;已处理`;
                            }
                            $("#historyPolice_list ul").append(`
                        <li style="overflow:hidden">
                            <div class="decter-stuts-con">
                                <span class='left alarming-being-processed' data-isReset = ` + data[i].isReset + `> ` +
                                dealResultHtml + `</span>
                            </div>
                            <a id="history_detail_` + data[i].id + `" href="#" class="item-link item-content" data-view=".view-main">
                                <div class="item-inner" style="padding: 0;">
                                    <div class="item-title-row" style="padding-right: 0;">
                                        <div class="item-title decter-name-con">
                                            <span class="decter-name">` + common.transNullundefinedToline(data[i]
                                .name) + `</span>
                                        </div>
                                    </div>
                                    <div class="item-subtitle decter-mesage">` + common.transNullundefined(data[i]
                                    .fcFacilitiesAddress) + `</div>
                                    <div class="item-subtitle decter-belong-unit">
                                        <i class="iconfont icon-dingweiweizhi" style="color: #2471CA;font-size: 14px;"></i>
                                        ` + common.transNullundefined(data[i].organizationName) + `
                                    </div>
                                </div>
                                <div class="decter-pic-con" id="dectorImg_` + data[i].id + `"></div>
                            </a>
                            <div class="decter-stuts-con" style="padding-left: 15px;border-top:0">
                                <span class='left' style="font-size:10px;    display: flex;align-items: center;flex-wrap: wrap;flex: 1;">
                                    <i id="fireType-` + data[i].id + `" class="iconfont ` + transNewFireIcon(data[i]
                                    .fireTTypes) + `" style="color:` + transFireColor(data[i]
                                    .fireTTypes) + `"></i>
                                    ` + transFireColorText(data[i].fireTTypes) + `
                                    <span style="color:#999;">持续` + common.transNullundefined(data[i]
                                .continueTimeStr) +
                                `</span>
                                </span>
                               
                            </div>
                            <div class="alarming-kepp-now"> 
                                <span class='right' style="font-size:10px;float: right;padding: 5px 15px;margin: 0 15px 20px 0;background: #397ECE;color:#fff;border-radius: 15px;" id="deal-btn-` +
                                data[i].id + `"
                                data-id = ` + data[i].id + `
                                data-createTime = ` + data[i].createTime + `
                                data-handlerStatus = ` + data[i].handlerStatus + `
                                data-organizationId = ` + data[i].organizationId + `
                                data-fireSTypes = ` + data[i].fireSTypes + `
                                data-fcFacilitiesId = ` + data[i].fcFacilitiesId + `
                                data-resetMode = ` + data[i].resetMode + `
                                >立即处理</span>
                            </div>
                        </li>
                    `);
                            //跳转
                            jQuery("#history_detail_" + data[i].id).off().on("click", {
                                'res': data[i]
                            }, function (e) {
                                var id = $(this).parent().find(".alarming-kepp-now span").attr(
                                    "data-id");
                                var createTime = $(this).parent().find(".alarming-kepp-now span")
                                    .attr("data-createTime");
                                var handlerStatus = $(this).parent().find(".alarming-kepp-now span")
                                    .attr("data-handlerStatus");
                                var organizationId = $(this).parent().find(
                                    ".alarming-kepp-now span").attr("data-organizationId");
                                var fireSTypes = $(this).parent().find(".alarming-kepp-now span")
                                    .attr('data-fireSTypes')
                                var fcFacilitiesId = $(this).parent().find(
                                    ".alarming-kepp-now span").attr('data-fcFacilitiesId')
                                var resetMode = $(this).parent().find(".alarming-kepp-now span")
                                    .attr('data-resetMode')
                                let alarming = {
                                    id: id,
                                    createTime: createTime,
                                    handlerStatus: handlerStatus,
                                    organizationId: organizationId,
                                    fireSTypes: fireSTypes,
                                    fcFacilitiesId: fcFacilitiesId,
                                    resetMode: resetMode
                                }
                                localStorage.setItem('ilink-alarming-push', JSON.stringify(
                                    alarming))
                                app.router.navigate(`/policeHistoryDetail/` + e.data.res
                                    .fcFacilitiesId + `/` + e.data.res.id + `/` + e.data.res
                                    .createTime + `/`);
                            })
                            //展示图片
                            if (data[i].icon != '' || data[i].icon == null || data[i].icon == undefined) {
                                showImage(jQuery("#dectorImg_" + data[i].id), JSON.parse(data[i].detailPic||'{}')
                                    .detailIcon, 1);
                            }

                            //立即处理
                            if (data[i].handlerStatus == -1) {
                                $("#deal-btn-" + data[i].id).show().html("立即处理");
                                $("#deal-btn-" + data[i].id).click(function (data) {
                                    var id = $(this).attr("data-id");
                                    var createTime = $(this).attr("data-createTime");
                                    var handlerStatus = $(this).attr("data-handlerStatus");
                                    var organizationId = $(this).attr("data-organizationId");
                                    var fireSTypes = $(this).attr('data-fireSTypes')
                                    var fcFacilitiesId = $(this).attr('data-fcFacilitiesId')
                                    var resetMode = $(this).attr('data-resetMode')
                                    let alarming = {
                                        id: id,
                                        createTime: createTime,
                                        handlerStatus: handlerStatus,
                                        organizationId: organizationId,
                                        fireSTypes: fireSTypes,
                                        fcFacilitiesId: fcFacilitiesId,
                                        resetMode: resetMode
                                    }
                                    localStorage.setItem('ilink-alarming-push', JSON.stringify(
                                        alarming))
                                    app.router.navigate(`/immediateAtten/` + id + `/` + moment(
                                            createTime).format("YYYY-MM-DD HH:mm:ss") + `/` +
                                        handlerStatus + `/` + organizationId + `/` +
                                        fireSTypes + `/` + fcFacilitiesId + `/`);
                                });
                            } else if (data[i].handlerStatus == 1) {
                                $("#deal-btn-" + data[i].id).hide();
                            } else {
                                $("#deal-btn-" + data[i].id).show().html("继续处理");
                                $("#deal-btn-" + data[i].id).click(function (data) {
                                    var id = $(this).attr("data-id");
                                    var createTime = $(this).attr("data-createTime");
                                    var handlerStatus = $(this).attr("data-handlerStatus");
                                    var organizationId = $(this).attr("data-organizationId");
                                    var fireSTypes = $(this).attr('data-fireSTypes')
                                    var fcFacilitiesId = $(this).attr('data-fcFacilitiesId')
                                    var resetMode = $(this).attr('data-resetMode')
                                    let alarming = {
                                        id: id,
                                        createTime: createTime,
                                        handlerStatus: handlerStatus,
                                        organizationId: organizationId,
                                        fireSTypes: fireSTypes,
                                        fcFacilitiesId: fcFacilitiesId,
                                        resetMode: resetMode
                                    }
                                    localStorage.setItem('ilink-alarming-push', JSON.stringify(
                                        alarming))
                                    app.router.navigate(`/immediateAtten/` + id + `/` + moment(
                                            createTime).format("YYYY-MM-DD HH:mm:ss") + `/` +
                                        handlerStatus + `/` + organizationId + `/` +
                                        fireSTypes + `/` + fcFacilitiesId + `/`);
                                });
                            }
                            if (data[i].isReset == 0) { //未复位
                                $("#deal-btn-" + data[i].id).show();
                            } else { //已复位
                                $("#deal-btn-" + data[i].id).show();
                            }
                            if (data[i].handlerStatus == 1) {
                                $("#deal-btn-" + data[i].id).hide();
                            }
                            if ($("#deal-btn-" + data[i].id).text() == '继续处理') {
                                if (data[i].handlerAccount == userInfor.accountName) {
                                    $("#deal-btn-" + data[i].id).show();
                                } else {
                                    $("#deal-btn-" + data[i].id).hide();
                                }
                            }
                            $("#historyPolice_list").click(function () {
                                $(".history-type-select-select")
                            });
                        }
                    } else {
                        self.allowInfinite = false;
                        $("#history_preloader").hide();
                        if (self.pageIndex == 0) { //暂无数据
                            $("#historyPolice_list ul").empty();
                            $("#historyPolice_list ul").append(`<div class="no-data-img"><img src="` +
                                listNoDataPic() + `"/></div>`);
                        }
                    }
                });
            },
            loadMoreHistoryList: function () {
                var self = this;
                if (!self.allowInfinite) return;
                self.allowInfinite = false;
                setTimeout(function () {
                    self.pageIndex++;
                    self.getHistoryPoliceList();
                    self.allowInfinite = true;
                }, 1000);
            },
            reInit: function () {
                var self = this;
                self.pageIndex = 0;
                $(".page-content").scrollTop(0, 300);
                $("#historyPolice_list ul").empty();
                if (!self.allowInfinite) {
                    self.allowInfinite = true;
                    $('#history_preloader').show();
                }
            },
            clearsearch: function (type, typeName) {
                jQuery("#historyPolice_list ul").empty();
                var self = this;
                self.selectContent = '';
                self.pageIndex = 0;
                self.getHistoryPoliceList();
            },
            clearContent: function () {
                if (userInfor.isMuilUnitUser == 0) {
                    if (this.fireSystemId != -1 || this.startTime != '' || this.fcfCategoryId != -1 || this
                        .fireTTypes != -1 || this.isDeal != "") {
                        $("#dec-search").addClass('search-select');
                    } else {
                        $("#dec-search").removeClass('search-select');
                    }
                } else {
                    if (this.historyOrgId != userInfor.organizationIds || this.fcfCategoryId != -1 || this
                        .fireSystemId != -1 || this.startTime != '' || this.fireTTypes != -1 || this.isDeal != "") {
                        $("#dec-search").addClass('search-select');
                    } else {
                        $("#dec-search").removeClass('search-select');
                    }
                }
            },
        },
        on: {
            pageInit: function (e, page) {
                var self = this;
                var app = self.$app;
                var $ = self.$$;
                self.historyOrgId = userInfor.organizationIds;
                jQuery('#history_fbs').click(() => {
                    app.popover.close('#dector_menu')
                    if(!this.fbsPopup){
                        this.fbsPopup=app.popup.create({
                            content:`<div id="fbsPopup" class="popup dector-popup" style="padding: 0;">`+
                                `<iframe id="fbsPopupIframe" src="${staticPathVue}#/ChooseFbs" style="width: 100%; height: 100%; border: none;"></iframe>`
                                +`</div>`
                        })
                    }
                    this.fbsPopup.open()
                })
                //选择单位
                //选择设备类别
                let selectOptionDecEltype = "";
                let dataType = 1;
                //设备类别
                jQuery("#history_type").click(function (e) {
                    loadSelectDectorFunc(self.historyOrgId, function (data) {
                        //选中
                        selectOptionDecEltype = data.type;
                        if (self.selectOptionDec != data.dectorId || dataType !=
                            selectOptionDecEltype) {
                            self.selectOptionDec = data.dectorId;
                            // 系统类别
                            if (data.type == 1) {
                                self.fireSystemId = data.dectorId;
                                self.fcfCategoryId = -1;
                                dataType = 1;
                            } else {
                                self.fireSystemId = data.sid;
                                self.fcfCategoryId = data.dectorId;
                                dataType = 2;
                            }
                            jQuery("#history_type").html(data.dectorName);
                            jQuery("#history_type").addClass('select-active');
                        } else {
                            self.selectOptionDec = "";
                            self.fireSystemId = -1;
                            self.fcfCategoryId = -1;
                            jQuery("#history_type").html("设备类别");
                            jQuery("#history_type").removeClass('select-active');
                        }
                        self.reInit();
                        self.clearContent();
                        self.getHistoryPoliceList();
                    }, false, self.selectOptionDec, selectOptionDecEltype, dataType);
                });
                jQuery("#history_org").click(function (e) {
                    loadSelectUnitFunc(function (data) {
                        //选中
                        if (self.selectOptionOrg != data.orgId) {
                            self.selectOptionOrg = data.orgId;
                            self.historyOrgId = data.orgId;
                            self.orgIds = data.orgId;
                            jQuery("#history_org").html(data.orgName);
                            jQuery("#history_org").addClass('select-active');
                            self.selectOptionDec = "";
                            self.fireSystemId = -1;
                            self.fcfCategoryId = -1;
                            jQuery("#history_type").html("设备类别");
                        } else {
                            self.selectOptionOrg = "";
                            self.historyOrgId = userInfor.organizationIds;
                            self.orgIds = userInfor.organizationIds;
                            jQuery("#history_org").html("选择单位");
                            jQuery("#history_org").removeClass('select-active');
                            self.selectOptionDec = "";
                            self.fireSystemId = -1;
                            self.fcfCategoryId = -1;
                            jQuery("#history_type").html("设备类别");
                        }
                        self.reInit();
                        self.clearContent();
                        self.getHistoryPoliceList();
                    }, self.selectOptionOrg);
                });
                if (userInfor.isMuilUnitUser == 0) { //单联网
                    $("#historyUnit-name").html(userInfor.org.name);
                    $("#his-select-down").hide();
                } else {
                    //是多联网角色切换到单的
                    if (isChangeUnitRole) {
                        self.historyOrgId = single_Orgid;
                        $("#historyUnit-name").html(single_OrgName);
                    } else {

                    }
                }
                self.reInit();
                if (userInfor.isMuilUnitUser == 0) { //单
                    self.historyOrgId = userInfor.organizationIds;
                    self.orgIds = userInfor.organizationIds;
                    $("#history_org").hide();
                } else { //多
                    //看板进来和工作天进来
                    if (this.$route.params.orgid == 0) {
                        self.historyOrgId = userInfor.organizationIds;
                        self.orgIds = userInfor.organizationIds;
                    } else {
                        self.historyOrgId = this.$route.params.orgid;
                        self.orgIds = this.$route.params.orgid;
                    }

                    $("#history_org").show();
                }
                //是否复位
                var policeType = [];
                var policeResult = [];
                policeResult.push({
                    "id": 10,
                    "text": "报警"
                });
                policeResult.push({
                    "id": 20,
                    "text": "故障"
                });
                policeResult.push({
                    "id": 30,
                    "text": "屏蔽"
                });
                policeResult.push({
                    "id": 40,
                    "text": "联动"
                });
                for (var i = 0; i < policeResult.length > 0; i++) {
                    var obj = {};
                    obj.id = policeResult[i].id;
                    obj.name = policeResult[i].text;
                    policeType.push(obj);
                }
                let selectOptionIndex2 = null;
                jQuery("#history_policeType").click(function (e) {
                    if (self.fireTTypes == -1) {
                        selectOptionIndex2 = "";
                    }
                    selectOptionFn(policeType, function (data) {
                        if (self.fireTTypes == data.id) {
                            $("#history_policeType").removeClass("select-active");
                            jQuery("#history_policeType").html("警情类型");
                            self.fireTTypes = -1;
                        } else {
                            jQuery("#history_policeType").html(data.name);
                            $("#history_policeType").addClass("select-active");
                            self.fireTTypes = data.id;
                        }
                        if (selectOptionIndex2 != data.index) {
                            selectOptionIndex2 = data.index;
                        } else {
                            selectOptionIndex2 = "";
                        }
                        self.reInit();
                        self.clearContent();
                        self.getHistoryPoliceList();
                    }, selectOptionIndex2);
                });


                //是否处理
                if (this.$route.params.handlerStatus == 0) {
                    self.isDeal = ""
                } else {
                    self.isDeal = this.$route.params.handlerStatus;
                }
                var dealType = [];
                var dealResult = [];
                dealResult.push({
                    "id": -1,
                    "text": "未处理"
                });
                dealResult.push({
                    "id": 2,
                    "text": "处理中"
                });
                dealResult.push({
                    "id": 1,
                    "text": "已处理"
                });
                for (var i = 0; i < dealResult.length > 0; i++) {
                    var obj = {};
                    obj.id = dealResult[i].id;
                    obj.name = dealResult[i].text;
                    dealType.push(obj);
                }
                let selectOptionIndex1 = null;
                jQuery("#history_isDeal").click(function (e) {
                    if (self.isDeal == "") {
                        selectOptionIndex1 = "";
                    }
                    selectOptionFn(dealType, function (data) {
                        if (self.isDeal == data.id) {
                            $("#history_isDeal").removeClass("select-active");
                            jQuery("#history_isDeal").html("是否处理");
                            self.isDeal = "";
                        } else {
                            jQuery("#history_isDeal").html(data.name);
                            $("#history_isDeal").addClass("select-active");
                            self.isDeal = data.id;
                        }
                        if (selectOptionIndex1 != data.index) {
                            selectOptionIndex1 = data.index;
                        } else {
                            selectOptionIndex1 = "";
                        }
                        self.reInit();
                        self.clearContent();
                        self.getHistoryPoliceList();
                    }, selectOptionIndex1);
                });
                //搜索
                jQuery("#historysearch-contant").keypress(function (e) {
                    let name = jQuery("#historysearch-contant").val();
                    if (e.which == 13) {
                        self.selectContent = name;
                        $("#historyPolice_list ul").empty();
                        self.pageIndex = 0;
                        self.getHistoryPoliceList();
                    };
                });

                //重现筛选条件
                if (localStorage.getItem("ilink_select_option")) {
                    var selectHistory = JSON.parse(localStorage.getItem("ilink_select_option"));
                    if (selectHistory.page == "historyPoliceApply") {
                        self.historyOrgId = selectHistory.organizationIds;
                        jQuery("#history_org").html(selectHistory.orgName).addClass('select-active');
                    }
                }

                // self.getHistoryPoliceList();
                this.getUserBuildByAccount()

            },
            pageBeforeOut: function (e, page) {
                var self = this;
                if (self.historyOrgId != userInfor.organizationIds) {
                    let params = {
                        page: 'historyPoliceApply',
                        organizationIds: self.historyOrgId,
                        orgName: jQuery("#history_org").html(),
                    }
                    saveSelectOption(params);
                }
            }
        }
    }
</script>